package Demo6;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Scanner;

public class delete {
    public static void main(String[] args) {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection connection = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=glxt", "sa", "sa123456");
            String sql = "delete from yh where yhmz = 'zjx'";

            // 指令预处理
            PreparedStatement statement = connection.prepareStatement(sql);

            // 获取结果集
            int ret = statement.executeUpdate();
            System.out.println("被修改行数: " + ret);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
